#include "EpollServer.hpp"
#include"Listen.hpp"
#include"Connect.hpp"

// ./select_server 8080
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    ENABLE_CONSOLE_LOG();
    uint16_t local_port = std::stoi(argv[1]);
    Listen _listen(local_port);
    std::shared_ptr<Connection> connection = std::make_shared<Connection>(_listen.GetSockfd());
    connection->Init([&_listen](){
        _listen.Accpte();
    },nullptr,nullptr);
    connection->SetEvents(EPOLLIN|EPOLLET);

    // std::unique_ptr<EpollServer> ssvr = std::make_unique<EpollServer>(local_port);
    // ssvr->Init();
    // ssvr->InsertEpoller(connection);
    // ssvr->Loop();
    
    EpollServer epoll_svr;
    epoll_svr.Init();
    epoll_svr.InsertEpoller(connection);
    epoll_svr.Loop();

    return 0;
}

